﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="LongSpeed.WebSite.Login" %>

<%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <title></title>
</head>
<body>
    <form runat="server" id="frm">
    <ext:Window ID="LoginForm" runat="server" Closable="false" Resizable="false" Height="175"
        Icon="Lock" Title="用户登陆" Draggable="false" Width="350" Modal="true" Padding="5"
        LabelAlign="Right" Layout="Form">
        <Defaults>
            <ext:Parameter Name="Anchor" Value="95%" />
            <ext:Parameter Name="AllowBlank" Value="false" Mode="Raw" />
            <ext:Parameter Name="SelectOnFocus" Value="true" Mode="Raw" />
            <ext:Parameter Name="MsgTarget" Value="side" />
        </Defaults>
        <Items>
            <ext:TextField ID="txtUsername" runat="server" FieldLabel="用户名" AllowBlank="false" AutoFocus="true" Margins="5" BlankText="您未输入用户名！" />
            <ext:TextField ID="txtPassword" runat="server" InputType="Password" FieldLabel="密　码" AllowBlank="false" BlankText="您未输入密码！" />
            <ext:TextField ID="txtVerificationCode" runat="server" MaxLength="4" FieldLabel="验证码" AllowBlank="false" BlankText="验证码不能为空哦！" />
            <%--<Listeners>
                    <Focus Handler="#{tip}.show()" />
                </Listeners>
            </ext:TextField>--%>
            <ext:Image runat="server" ImageUrl="Behaviors/imgChar.ashx" Width="60" Height="20"
                AnchorHorizontal="50%">
                <LoadMask Msg="Loading" ShowMask="true" />
            </ext:Image>
        </Items>
        <Buttons>
            <ext:Button ID="btnLogin" runat="server" Text="登陆" Icon="Accept">
                <Listeners>
                    <Click Handler="Validte()" />
                </Listeners>
            </ext:Button>
        </Buttons>
        <KeyMap>
            <ext:KeyBinding>
                <Keys>
                    <ext:Key Code="ENTER" />
                </Keys>
                <Listeners>
                    <Event Fn="Validte" />
                </Listeners>
            </ext:KeyBinding>
        </KeyMap>
    </ext:Window>
    <%--<ext:ToolTip ID="tip" AutoDestroy="false" AutoShow="true" Target="txtVerificationCode"
        Collapsed="false" Frame="true" AutoHide="false" Draggable="false" runat="server"
        Html="<img src='Behaviors/imgChar.ashx' alt='验证码' width='60' height='20' />">
        <LoadMask ShowMask="true" Msg="Loading" />
    </ext:ToolTip>--%>
    <script type="text/javascript" language="javascript">
        function Validte() {

            var vali = txtUsername.validate() && txtPassword.validate() && txtVerificationCode.validate();
            if (!vali) {
                Ext.Msg.alert("错误", "表单验证不通过，请认真仔细填写数据。");
                return false;
            }

            var mk = new Ext.LoadMask(Ext.get("frm"), {
                msg: '正在加载数据，请稍候……',
                //完成后移除  
                removeMask: true,                
            });
            mk.show(); //显示  

            Ext.net.DirectMethods.UserLogin({
                success: function (result) {
                    if (typeof( result) =="object") {
                        mk.hide();
                        LoginForm.hide();
                    }
                    else
                    {
                        mk.hide();
                        Ext.Msg.alert("提示", result);
                    }
                },
                failure: function (msg) {
                    mk.hide();
                    Ext.Msg.alert("提示", "操作失败！<br /> 详细：" + msg);
                }
            });
        }
    </script>
    </form>
</body>
</html>
